﻿// 给定一个类型: 

// 现有一个集合

using LinqNote;

var books = new List<Book>
{
    new("book1", 12.0, 1, 1, "xxx"),
    new("book2", 22.0, 2, 1, "xxy"),
    new("book3", 31.0, 3, 1, "xyx"),
    new("book4", 42.0, 4, 2, "xyy"),
    new("book5", 19.0, 5, 2, "yxx"),
    new("book6", 24.0, 6, 3, "yxy"),
    new("book7", 32.0, 7, 3, "yyx")
};

var authors = new List<Author>
{
    new("xxx", 20),
    new("xxy", 8),
    new("xyx", 5),
    new("xyy", 10)
};

// 请算出书籍价格的平均数, 并获取书籍价格大于平均数的书籍名称列表
var bookNameList = books.Where(book => book.Price > books.Average(x => x.Price)).Select(book => book.BookName).ToList();

// 算出作者卖出书籍的总收入.并取收入为前两名的作者名称以及收入额
var authorIncomes = books.Join(authors,
        book => book.author,
        author => author.Name,
        (book, author) => new AuthorIncome(author.Name, book.Price * author.Sales))
    .OrderByDescending(x => x.TotalAmount).Take(2).ToList();

Console.WriteLine();